package com.jlastu.dlxy_androidapp.view.main;

import android.content.Intent;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;
import android.view.View;

import androidx.appcompat.app.AppCompatActivity;

import com.jlastu.dlxy_androidapp.R;
import com.jlastu.dlxy_androidapp.utils.SpUtils;
import com.jlastu.dlxy_androidapp.view.login.LoginActivity;
import com.jlastu.dlxy_androidapp.view.setting.AddressSettingsActivity;
import com.jlastu.dlxy_androidapp.view.setting.ChangePasswordActivity;
import com.jlastu.dlxy_androidapp.view.setting.ExitActivity;
import com.jlastu.dlxy_androidapp.view.setting.PrivacyActivity;

public class SettingsActivity extends AppCompatActivity {
    private SpUtils mSpUtils;
    @Override
    public void onConfigurationChanged(android.content.res.Configuration newConfig) {
        super.onConfigurationChanged(newConfig);

        // 检查屏幕方向是否为横屏
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            Log.d("Orientation", "Landscape detected");

            // 创建并启动新的Activity
            Intent intent = new Intent(this, LandscapeActivity.class);
            startActivity(intent);

            // 可选：关闭当前Activity
            finish();
        }
    }
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.settings_layout);
        mSpUtils = new SpUtils(getApplicationContext());

    }

    public void openAddressSettings(View view) {
        // 打开我的收货地址设置界面
        Intent intent = new Intent(this, AddressSettingsActivity.class);
        startActivity(intent);
    }

    public void openPrivacySettings(View view) {
        // 打开隐私设置界面
        Intent intent = new Intent(this, PrivacyActivity.class);
        startActivity(intent);
    }

    public void openChangePassword(View view) {
        // 打开修改密码界面
        Intent intent = new Intent(this, ChangePasswordActivity.class);
        startActivity(intent);
    }

    public void logout(View view) {
        mSpUtils.deleteInt("userid");
        // 执行退出登录操作
        Intent intent = new Intent(SettingsActivity.this, LoginActivity.class);
        startActivity(intent);
        finishAffinity();


    }
}